if exists (select 1
            from  sysobjects
           where  id = object_id('bd_kq_approve_detail')
            and   type = 'U')
   drop table bd_kq_approve_detail
go

/*==============================================================*/
/* Table: bd_kq_approve_detail                                  */
/*==============================================================*/
create table bd_kq_approve_detail (
   id                   int                  identity,
   approve_id           varchar(64)          not null,
   approve_key          varchar(64)          not null,
   approve_order        int                  not null,
   group_id             int                  not null default 0,
   constraint PK_BD_KQ_APPROVE_DETAIL primary key (id)
)
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve_detail')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'id')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve_detail', 'column', 'id'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '自增',
   'user', @CurrentUser, 'table', 'bd_kq_approve_detail', 'column', 'id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve_detail')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'approve_id')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve_detail', 'column', 'approve_id'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '审批流程表ID',
   'user', @CurrentUser, 'table', 'bd_kq_approve_detail', 'column', 'approve_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve_detail')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'approve_key')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve_detail', 'column', 'approve_key'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '流程的KEY',
   'user', @CurrentUser, 'table', 'bd_kq_approve_detail', 'column', 'approve_key'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve_detail')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'approve_order')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve_detail', 'column', 'approve_order'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '流程序号',
   'user', @CurrentUser, 'table', 'bd_kq_approve_detail', 'column', 'approve_order'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve_detail')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'group_id')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve_detail', 'column', 'group_id'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '审批组ID',
   'user', @CurrentUser, 'table', 'bd_kq_approve_detail', 'column', 'group_id'
go
